

package Database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * Compiler: jdk1.6.0_14 <br />
 * IDE: NetBeans 6.7.1 <br />
 * @author Andrew Smith <br />
 */
public class DataHandler
{

    private Connection connection;

    public DataHandler()
    {
        connection = getConnection();
    }





    private Connection getConnection()
    {
        String driver = "com.mysql.jdbc.Driver";
        String database = "teamawes_skant";
        String url = "jdbc:mysql://localhost/" + database;

        String user = "root";
        String pw = "enter";
        Connection con = null;
        try
        {
            Class.forName(driver).newInstance();
            con = DriverManager.getConnection(url, user, pw);
        }
        catch(SQLException ex)
        {
            for(int i=0; i<ex.getStackTrace().length; i++)
            {
                System.out.println(ex.getStackTrace()[i]);
            }
            System.out.println(ex.getMessage());
            System.exit(-1);
        }
        catch(Exception ex)
        {
            for(int i=0; i<ex.getStackTrace().length; i++)
            {
                System.out.println(ex.getStackTrace()[i]);
            }
            System.out.println(ex.getMessage());
            System.exit(-1);
        }

        return con;
    }



    public static void main(String[] args)
    {
        DataHandler data = new DataHandler();
    }
}
